﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using DealerClient.CGService;

namespace DealerClient
{
    public partial class frmDealer : Form
    {
        public frmDealer()
        {
            InitializeComponent();
        }

        private void cmdTest_Click(object sender, EventArgs e)
        {
            loadGrid();
        }

        private void tmrGridRefresh_Tick(object sender, EventArgs e)
        {
            loadGrid();
        }

        private void frmDealer_Load(object sender, EventArgs e)
        {
            loadGrid();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void loadGrid()
        {
            CardGameServiceClient client = new CardGameServiceClient();
            Dictionary<Player, PlayerCards[]> pcs = client.GetCurrentTableView();

            PlayerCards[] pc = null;
            List<PlayerCards> playercards = new List<PlayerCards>();
            foreach (Player p in pcs.Keys)
            {
                pcs.TryGetValue(p, out pc);
                playercards.AddRange(pc);
            }
            dataGridView1.DataSource = playercards;
            dataGridView1.Update();
            client.Close();
            client = null;
        }
    }
}
